import request from '@/utils/request'

// 查询班级学员明细列表
export function listClassStudent(query) {
  return request({
    url: '/training/ClassStudent/list',
    method: 'get',
    params: query
  })
}

// 查询班级学员明细详细
export function getClassStudent(classStudentId) {
  return request({
    url: '/training/ClassStudent/' + classStudentId,
    method: 'get'
  })
}

// 新增班级学员明细
export function addClassStudent(data) {
  return request({
    url: '/training/ClassStudent',
    method: 'post',
    data: data
  })
}

// 修改班级学员明细
export function updateClassStudent(data) {
  return request({
    url: '/training/ClassStudent',
    method: 'put',
    data: data
  })
}

// 删除班级学员明细
export function delClassStudent(classStudentId) {
  return request({
    url: '/training/ClassStudent/' + classStudentId,
    method: 'delete'
  })
}

// 根据班级ID查询所有报名信息和学员信息，支持多字段模糊搜索
export function getClassStudents(params) {
  return request({
    url: `/training/ClassStudent/getClassStudents/${params.trainingClassId}`,
    method: 'get',
    params: {
      studentName: params.studentName,
      phonenumber: params.phonenumber,
      idNumber: params.idNumber
    }
  })
}

/**
 * 批量进班（支持单个）
 * @param classStudentList 班级学员列表
 */
export function batchJoin(classStudentList) {
  return request({
    url: '/training/ClassStudent/batchJoin',
    method: 'post',
    data: classStudentList
  });
}

/**
 * 批量退班（支持单个
 * @param classStudentList 班级学员列表
 */
export function batchQuit(classStudentList) {
  return request({
    url: '/training/ClassStudent/batchQuit',
    method: 'post',
    data: classStudentList
  });
}

// 通过学员id获取学员的考试情况
export function getExamInfoByStudentId(studentId) {
  return request({
    url: '/training/ClassStudent/getExamInfoByStudentId/' + studentId,
    method: 'get'
  })
}

// 通过学员id获取学员的考试安排
export function getExamScheduleByStudentId(trainingClassId,studentId) {
  return request({
    url: '/training/ClassStudent/getExamScheduleByStudentId/' + studentId,
    method: 'get',
    params:{
      trainingClassId:trainingClassId
    }
  })
}
